<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('评价打分')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-taskDetail-edit" th:object="${evaTaskDetail}">
            <input name="taskDetailId" th:field="*{taskDetailId}" type="hidden">
            <!--<div class="form-group">
                <label class="col-sm-3 control-label is-required">参评部门id：</label>
                <div class="col-sm-8">
                    <input name="deptId" th:field="*{deptId}" class="form-control" type="text" required>
                </div>
            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">年份：</label>
                <div class="col-sm-8">
                    <input name="year" th:field="*{year}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">任务名称：</label>
                <div class="col-sm-8">
                    <input name="taskName" th:field="*{taskName}" class="form-control" type="text" readonly required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合同名称：</label>
                <div class="col-sm-8">
                    <input name="contractName" th:field="*{contractName}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">合同收支类型：</label>
                <div class="col-sm-8">
                    <select name="contractClass" class="form-control m-b" th:with="type=${@dict.getType('contract_class')}" required disabled="disabled">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{contractClass}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">合同类型：</label>
                <div class="col-sm-8">
                    <select name="contractType" class="form-control m-b" th:with="type=${@dict.getType('contract_type')}" required disabled="disabled">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{contractType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合约方名称：</label>
                <div class="col-sm-8">
                    <input name="targetName" th:field="*{targetName}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">评分：</label>
                <div class="col-sm-8">
                    <input name="score" th:field="*{score}" class="form-control" type="number" min="0" max="100">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">附件信息：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="filePath" name="filePath" th:field="*{filePath}" class="form-control" type="text" readonly>
                        <span class="input-group-addon"><i class="fa fa-download" style="color: #67b168" onclick="downloadFile()">下载</i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">附件上传</label>
                <div class="col-sm-8">
                    <div class="input-group file-loading">
                        <input id="singleFile" name="file" type="file">
                    </div>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "credit/taskDetail";
        $("#form-taskDetail-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-taskDetail-edit').serialize());
            }
        }

        // 文件上传
        $("#singleFile").fileinput({
            uploadUrl: ctx + 'common/evaTask/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            var rsp = data.response;
            $("#filePath").val(rsp.filePath);
            log.info("return filePath：" + rsp.filePath)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })

        // 下载附件
        function downloadFile(){
            var filePath = $("#filePath").val();
            if(filePath == ''){
                $.modal.msgError('没有附件！');
            } else {
                window.location.href = ctx + "common/download/resource?resource=" + filePath;
            }
        }
    </script>
</body>
</html>
